package ui.swing.applet.javascript;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.AbstractAction;
import javax.swing.JApplet;
import javax.swing.JButton;

public class InvokingJsByProtocal extends JApplet {
	
	private JButton v_btnInvokeByProtocal;

	@Override
	public void start() {
		add(getV_btnInvokeByProtocal(), BorderLayout.CENTER);
	}

	private JButton getV_btnInvokeByProtocal() {
		if (v_btnInvokeByProtocal == null) {
			v_btnInvokeByProtocal = new JButton(new AbstractAction("Call 、\"doAlert\"") {
				public void actionPerformed(ActionEvent e) {
					String msg = "Hello from Java (using javascript alert)";
					try {
						getAppletContext().showDocument(new URL("javascript:doAlert(\"" + msg + "\")"));
					} catch (MalformedURLException me) {
						me.printStackTrace();
					}
				}
			});
		}
		return v_btnInvokeByProtocal;
	}
	

	
}
